import java.util.Arrays;
import java.util.HashMap;

public class L1 {
    public static void main(String[] args) {
        int[] nums = {-3, 4, 3, 90};
        int target = 0;
        int[] ints = new Solution().twoSum(nums, target);
        System.out.println(Arrays.toString(ints));


    }

    static class Solution {
        public int[] twoSum(int[] nums, int target) {

            HashMap<Integer, Integer> map = new HashMap<>(nums.length);
            for (int i = 0; i < nums.length; i++) {
                int other = target - nums[i];
                Integer index = map.get(other);
                if (index != null) {
                    return new int[]{index, i};
                }
                map.put(nums[i], i);

            }
            return null;
        }
    }
}
